home *** CD-ROM | disk | FTP | other *** search
- /*
- File ResEd.h
-
- Copyright Apple Computer, Inc. 1984-1990
- All rights reserved.
-
- Resource editor interface unit for instances of editors and pickers. This should be
- included by any C implementation of a resource editor or picker. The
- companion file ResDisp.a.o should be linked with the c module to build
- the file for inclusion in ResEdit.
-
- Pickers are given a resource type and should display all of that type in
- the current resfile in a suitable format. If the picker is given an open call
- AND there's a compatible editor, it should give birth to the Editor. The editor
- is given a handle to the resource object and it should open up an edit
- window for the user.
-
- Note that anybody can open pickers and editors so, for instance, a dialog item list
- editor might open an icon Picker for the user to choose an appropriate icon.
- The user could also, while in the icon picker, open the icon editor to create
- a new icon if desired.
-
- */
-
- #include <types.h>
- #include <quickdraw.h>
- #include <lists.h>
- #include <controls.h>
- #include <windows.h>
- #include <events.h>
- #include <dialogs.h>
- #include <printing.h>
-
- /* Standard menus exported by ResEdit */
-
- #define fileMenu 2
-
- #define newFileItem 1
- #define openFileItem 2
- #define openSpecialItem 3
- #define closeItem 4
- #define saveItem 5
- #define revertItem 6
- #define getThisInfoItem 8
- #define getInfoItem 9
- #define verifyItem 10
- #define pageSetupItem 12
- #define printItem 13
- #define preferencesItem 15
- #define quitItem 17
-
- // Masks for AbleMenu - normally not used directly.
- #define newFileMask 0x2
- #define openFileMask 0x4
- #define openSpecialMask 0x8
- #define closeMask 0x10
- #define saveMask 0x20
- #define revertMask 0x40
- #define getThisInfoMask 0x100
- #define getInfoMask 0x200
- #define verifyMask 0x400
- #define pageSetupMask 0x1000
- #define printMask 0x2000
- #define preferencesMask 0x8000
- #define quitMask 0x20000
- #define disabledMask 0x1
-
- // Mask combinations to be used in calls to AbleMenu.
- #define fileNotOpen disabledMask + newFileMask + openFileMask + openSpecialMask + getInfoMask + verifyMask + pageSetupMask + preferencesMask + quitMask
- #define fileNoPrint fileNotOpen + getThisInfoMask + closeMask + saveMask + revertMask
- #define fileAll fileNoPrint + printMask
- #define fileDA disabledMask + closeMask + quitMask
-
- #define rsrcMenu 128
-
- #define rsrcCreateItem 1
- #define rsrcOpenItem 2
- #define rsrcOpenTemplateItem 3
- #define rsrcOpenHexItem 4
- #define rsrcRevertItem 6
- #define rsrcGetInfoItem 8
-
- #define rsrcCreateMask 0x2
- #define rsrcOpenMask 0x4
- #define rsrcOpenTemplateMask 0x8
- #define rsrcOpenHexMask 0x10
- #define rsrcRevertMask 0x40
- #define rsrcGetInfoMask 0x100
- #define rsrcDisabledMask 0xFFFFFE01
-
- #define rsrcDisabled 0xFFFFFE00
- #define rsrcRevertOnly rsrcDisabledMask + rsrcRevertMask
- #define rsrcPickerNoSel rsrcDisabledMask + rsrcCreateMask
- #define rsrcFilePicker rsrcPickerNoSel + rsrcRevertMask + rsrcOpenMask
- #define rsrcRsrcPicker rsrcFilePicker + rsrcOpenHexMask + rsrcOpenTemplateMask + rsrcGetInfoMask
- #define rsrcEditor rsrcDisabledMask + rsrcRevertMask + rsrcGetInfoMask
- #define rsrcEditorPicker rsrcEditor + rsrcOpenMask + rsrcOpenTemplateMask + rsrcOpenHexMask
- #define rsrcDITLEd rsrcEditorPicker - rsrcOpenHexMask + rsrcCreateMask
- #define rsrcEditorCreate rsrcEditor + rsrcCreateMask
-
- #define editMenu 3
-
- #define undoItem 1
- #define cutItem 3
- #define copyItem 4
- #define pasteItem 5
- #define clearItem 6
- #define dupItem 8
- #define selectAllItem 9
- #define selectChangedItem 10
-
- /* Masks for AbleMenu - normally not used directly. */
- #define undoMask 0x2
- #define cutMask 0x8
- #define editCopyMask 0x10
- #define pasteMask 0x20
- #define clearMask 0x40
- #define duplicateMask 0x100
- #define selectAllMask 0x200
- #define selectChangedMask 0x400
- #define editDisabledMask 0xFFFFF801
-
- /* Mask combinations to be used in calls to AbleMenu. */
- #define editNone editDisabledMask - 1
- #define editClear editDisabledMask + clearMask
- #define editCopy editDisabledMask + editCopyMask
- #define editPaste editDisabledMask + pasteMask
- #define editUndoPasteOnly editPaste + undoMask
- #define editDup editClear + duplicateMask
- #define editNoDup editDisabledMask + cutMask + editCopyMask + pasteMask + clearMask /* No dup or undo */
- #define editNoUndo editNoDup + duplicateMask
- #define editUndNoDup editNoDup + undoMask
- #define editAll editNoUndo + undoMask
- #define editAcc editUndNoDup /* for DAs */
-
- #define viewMenu 130 /* Type pickers view menu. */
-
- #define viewByIDItem 1
- #define viewByNameItem 2
- #define viewBySizeItem 3
- #define viewByOrderItem 4
- #define viewBySpecialItem 5
- #define viewShowAttributesItem 7
-
- /* Masks for AbleMenu. */
- #define viewByIDMask 0x2
- #define viewByNameMask 0x4
- #define viewBySizeMask 0x8
- #define viewByOrderMask 0x10
- #define viewBySpecialMask 0x20
- #define viewShowAttributesMask 0x40
- #define viewDisabledMask 0xFFFFFF81
-
- #define viewNoSpecial viewDisabledMask + viewByIDMask + viewByNameMask + viewBySizeMask + viewByOrderMask
- #define viewNoAttributes viewNoSpecial + viewBySpecialMask
- #define viewAll viewNoAttributes + viewShowAttributesMask
-
- #define editorNameChr 0 /* First char of the name for editors */
-
- /* Standard strings available by calling GetStr. */
- #define editStrings 130 /* Resource ID of STR# resource containing the strings. */
- #define undoChangeStr 1
- #define redoChangeStr 2
- #define undoCutStr 3
- #define redoCutStr 4
- #define undoCopyStr 5
- #define redoCopyStr 6
- #define undoClearStr 7
- #define redoClearStr 8
- #define undoTypingStr 9
- #define redoTypingStr 10
- #define undoPasteStr 11
- #define redoPasteStr 12
- #define undoStr 13
-
- #define miscStrings 129 /* Resource ID of STR# resource containing the strings. */
- #define miscStringsName "\pMisc"
- #define fromStr 1 /* String for window titles. */
- #define cantLoadSndErrStr 24 /* Snd picker error. */
- #define fullWindowStr 38 /* String for the resizeWind menu item */
- #define ownerWindowWindowStr 39
- #define newItemStr 40 /* Enter new item number */
- #define selectItemStr 41 /* Open which item? */
- #define clipBoardErrorStr 42 /* Error accessing the Clipboard. */
- #define sndErrorStr 43 /* Error playing a sound. */
- #define openUsingStr 44 /* Open using Template… */
- #define openAsDITMStr 45 /* Open As Dialog Item */
- #define openDITMStr 77 /* Open Item */
-
- /* Text for selected errors */
- #define errorStrings 132 /* Resource ID of STR# resource containing the error strings */
- #define errorStringsName "\pErrors"
- #define genericErrStr 1 /* Returned by GetErrorText when no specific message available */
- #define ioErrStr 1
- #define writeProtectErrStr 2
- #define diskFullErrStr 3
- #define fileLockedErrStr 4
- #define outOfMemoryErrStr 5
- #define alreadyOpenErrStr 6
- #define tooManyOpenErrStr 7
- #define volNotMountedErrStr 8
- #define resNotFoundErrStr 9
- #define accessErrStr 10
- #define resFileNotFoundErrStr 11
- #define addResFailErrStr 12
- #define removeResFailErrStr 13
- #define resAttributesErrStr 14
- #define resMapErrStr 15
- #define fileNotFoundErrStr 16
- #define eofErrStr 17
-
- #define arrowCursor -1 /* Used in the call to SetTheCursor to set the arrow cursor. */
-
- #define minPickStdWidth 150
- #define minPickStdHeight 64
-
- #define theScrollBar 15 /* Width of a scroll bar. */
- #define pickerGaps 6; /* 4 bet graphic & frame, 2 for frame */
-
- #define okChoice 1
-
- #define noDialog 0
-
- #define alertStringsName "\pAlert strings"
- #define badCharAlert 1 /* ALRT, DLOG, WIND editors */
- #define revertResourceAlertStr 2
- #define noTemplateAlert 6 /* GNRL editor */
- #define cantPlayOnThisMachineAlert 7 /* snd picker */
- #define cantPlaySndAlert 8 /* snd picker */
-
- /* Consts for Resource menu string */
- #define rsrcStrName "\pResource menu"
- #define rsrcCreateStr 1
- #define rsrcOpenStr 2
- #define rsrcListStr 3
- #define rsrcOpenLists 4
- #define rsrcOpenEditor 5
- #define rsrcOpenEditors 6
- #define rsrcOpenHex 7
- #define rsrcRevert 8
- #define rsrcRevertThese 9
- #define rsrcResources 10
- #define rsrcRevertRes 11
- #define rsrcRevertThis 12
- #define rsrcPatCreateStr 13
- #define rsrcSICNCreateStr 14
- #define rsrcDITLCreateStr 15
- #define rsrcRevertItemStr 16
- #define rsrcGNRLCreateStr 17
-
- /* ViewTypes to be used with the viewBy item in the PickRec */
- #define viewById 0
- #define viewByName 1
- #define viewBySize 2
- #define viewByOrder 3
- #define viewBySpecial 4
-
- /* Alert kinds used by the DisplayAlert procedure. */
-
- typedef enum { displayTheAlert, displayStopAlert, displayNoteAlert, displayCautionAlert,
- displayYNAlert, displayYNCAlert, displayYNCStopAlert } AlertType;
-
- /* private string type }
-
- typedef unsigned char Str64[65];
-
- /* map entry definition for new resource manager call */
- typedef struct {
- short rID;
- short rNameOff;
- long rLocn;
- Handle rHndl;
- } ResMapEntry;
-
- /* This structure is used by the GetQuickDrawVars procedure. */
- typedef struct {
- long randSeed;
- BitMap screenBits;
- Cursor arrow;
- Pattern dkGray;
- Pattern ltGray;
- Pattern gray;
- Pattern black;
- Pattern white;
- GrafPtr thePort;
- } QuickDrawVars;
- typedef QuickDrawVars *pQuickDrawVars;
-
- /* Each driver has its own object handle. This has to start with a handle
- to its parent's object followed by the name distinguishing the father
- This name will be part of the son's window title. The next field should
- be the window of the obj (may be used by son to get back to the father
- (through the refcon in the windowRec). The next field is the rebuild flag
- used to indicate that a windows data (e.g. a pickers list) needs to be
- recalculated at the next opportunity. The rest of the handle can be of
- any format. The name for pickers should be the name of the file or disk.
- For editors, the name should be the complete name (not the windows title)
- preceded by an editorNameChr character (see const above). An example of a
- complete name would be "ALRT ID = -1234 from AFile". This name is used to
- uniquely identify a window.
-
- See the manual for detailed documentation of this interface file. */
-
- typedef struct ParentRec {
- struct ParentRec **father;
- Str255 name; /* Max 255 characters */
- WindowPeek wind;
- Boolean rebuild; /* flag set by son to indicate that world */
- /* has changed so father should rebuild list */
- } ParentRec;
-
- typedef ParentRec *ParentPtr;
- typedef ParentPtr *ParentHandle;
-
- /* Standard picker record */
-
- typedef struct PickRec {
- ParentHandle father; /* Back ptr to dad */
- Str255 fName; /* Max 255 characters. */
- WindowPtr wind; /* Directory window */
- Boolean rebuild;
- short pickID; /* ID of this picker */
- ResType rType; /* Type for this picker */
- short rNum; /* resfile number */
- long rSize; /* size of a null resource */
- short nInsts; /* Number of instances */
- ListHandle instances; /* List of instances */
- Ptr drawProc; /* List draw proc */
- ControlHandle scroll; /* Scroll bar */
- short viewBy; /* Current view type */
- ResType ldefType; /* Which LDEF to use */
- MenuHandle theViewMenu; /* The picker view menu */
- Boolean showAttributes; /* Show attrs in window? */
- long viewMenuMask; /* Which items are enabled? */
- Cell cellSize; /* Size for special view. */
- } PickRec;
-
- typedef PickRec *PickPtr;
- typedef PickPtr *PickHandle;
-
- typedef pascal void (*DrawResProcPtr) (Rect *lRect, Handle theIcon);
-
-
- /* These routines are used to start pickers and editors.*/
-
- pascal void GiveEBirth(Handle resHandle, PickHandle pick);
- pascal void GiveThisEBirth(Handle resHandle, PickHandle pick, ResType openThisType);
- pascal void GiveSubEBirth(Handle resHandle, PickHandle pick);
-
- /* These routines are used to feed events and menu calls to the appropriate picker or editor. */
-
- pascal void CallInfoUpdate(short oldID, short newID, long object, short id);
- pascal void PassMenu(short menu, short item, ParentHandle father);
-
- /* Window Utilities */
-
- pascal Boolean AlreadyOpen (StringPtr windowTitle, StringPtr windowName, ParentHandle father);
- pascal WindowPtr PickerWindSetup (Boolean color, short width, short height, StringPtr windowTitle,
- short windowKind, ParentHandle father);
- pascal WindowPtr EditorWindSetup (short dlogID, Boolean color, short width, short height, StringPtr windowTitle,
- StringPtr windowName, Boolean addFrom, short windowKind, ParentHandle father);
- pascal void GetWindowTitle (StringPtr windowTitle, StringPtr windowName, Boolean addFrom,
- ParentHandle father);
- pascal void SetETitle(Handle h, StringPtr str);
- pascal WindowPtr WindAlloc(void);
- pascal void WindReturn(WindowPtr w);
- pascal ListHandle WindList(WindowPtr w, short nAcross, Point cSize, short drawProc);
- pascal void WindOrigin(WindowPtr w, ParentHandle father);
-
-
- /* Extended Resource Manager */
-
- pascal short CurrentRes(void);
- pascal Handle Get1Index(ResType, short index);
- pascal Handle Get1Res(ResType, short id);
- pascal Handle ResEditGet1Resource (ResType theType, short id, Boolean *wasLoaded, short *error);
- pascal Boolean NeedToRevert (WindowPtr myWindow, Handle theRes);
- pascal void RemoveResource (Handle theRes);
- pascal Boolean RevertThisResource (ParentHandle theObj, Handle theRes);
- pascal Boolean RestoreRemovedResources (PickHandle pick);
- pascal void ResourceIDHasChanged (ParentHandle theObj, ResType theType, short theOldId, short theNewId);
- pascal short SysResFile(void);
- pascal short BeautifulUnique1ID (ResType t);
-
-
- /* Miscellaneous utilities */
-
- pascal void Abort(void);
- pascal void AbleMenu(short menu, long enable);
- pascal Boolean AddNewRes(Handle hNew, ResType t, short idNew, StringPtr s);
- pascal void BubbleUp(Handle);
- pascal short BuildType(ResType t, ListHandle l);
- pascal Boolean CheckError(short err, short msgID);
- pascal Boolean CloseNoSave(void);
- pascal void ConcatStr(StringPtr str1, StringPtr str2);
- pascal short DefaultListCellSize(void);
- pascal void CenterDialog (ResType theType, short dialog);
- pascal Boolean DisplaySTRAlert(AlertType which, StringPtr STRName, short STRIndex);
- pascal short DisplayAlert(AlertType which, short id);
- pascal Boolean DoPickBirth(Boolean color, Boolean buildList, short wWidth, short wHeight,
- short columns, short pickerResId, PickHandle pick);
- pascal void DrawLDEF (short message, Boolean lSelect, const Rect *lRect, Handle theRes,
- short id, StringPtr title, short maxH, short maxV,
- DrawResProcPtr DrawResource, ListHandle lh);
- pascal void DrawMBarLater(Boolean forceItNow);
- pascal WindowPtr FindOwnerWindow (Handle theRes);
- pascal void FixHand(long s, Handle h);
- pascal void FlashDialogItem (DialogPtr dp, short item);
- pascal void FrameDialogItem (DialogPtr dp, short item);
- pascal pQuickDrawVars GetQuickDrawVars(void);
- pascal void GetStr(short num, short list, StringPtr str);
- pascal void GetNamedStr(short index, StringPtr name, StringPtr str);
- pascal void GrowMyWindow (short minWidth, short minHeight, WindowPtr windPtr, ListHandle);
- pascal Boolean HandleCheck(Handle h, short msgID);
- pascal void MetaKeys(Boolean *cmd, Boolean *shift, Boolean *opt);
- pascal Handle NewRes(long s, ResType t, ListHandle l, short *n);
- pascal void PickEvent(EventRecord *evt, PickHandle pick);
- pascal void PickInfoUp(short oldID, short newID, PickHandle pick);
- pascal void PickMenu(Boolean tossOnClose, short menu, short item, PickHandle pick);
- pascal short PickStdHeight(void);
- pascal short PickStdWidth(void);
- pascal Handle PrintSetup(void); /* Return type is actually THPrint */
- pascal void PrintWindow (PicHandle toPrint);
- pascal short ResEdID(void);
- pascal void SendRebuildToPicker (ResType theType, ParentHandle parent);
- pascal void SendRebuildToPickerAndFile (ResType theType, ParentHandle parent) ;
- pascal void SetResChanged(Handle h);
- pascal void SetTheCursor (short whichCursor);
- pascal void ShowInfo(Handle h, ParentHandle father);
- pascal void TypeToString(ResType t, StringPtr s);
- pascal void UseAppRes(void);
- pascal Boolean WasAborted(void);
- pascal Boolean WasItLoaded(void);
- pascal Boolean ColorAvailable(void);
-
- /* Color Palette Popup Menus */
-
- pascal void InstallColorPalettePopup( WindowPtr whichWindow, Boolean CQDishere,
- Boolean isActive );
- pascal void DrawColorPopup( WindowPtr whichWindow, Rect *itemBox,
- RGBColor *whichColor, Boolean CQDishere );
- pascal Boolean ColorPalettePopupSelect( WindowPtr whichWindow, Rect *itemBox,
- RGBColor *whichColor, Boolean CQDishere );
- pascal void DeinstallColorPalettePopup( WindowPtr whichWindow, Boolean CQDishere );
-
- /* Routines that are used internally withing ResEdit and may be useful in other
- circumstances. */
-
- pascal ResType MapResourceType (Boolean editor, Handle theRes, ResType origResType);
- pascal void DoKeyScan(EventRecord *evt, short offset, ListHandle lh);
- pascal Handle DupPick(Handle h, Cell c, PickHandle pick);
- pascal Boolean GetType(Boolean templatesOnly, StringPtr s);
- pascal void KillCache(void);
- pascal void RCalcMask(Ptr srcPtr, Ptr dstPtr,
- short srcRow, short dstRow, short height, short words);
- pascal short ResEditRes(void) =
- {0x3eB8, 0x0900}; /* move.w CurApRefNum,(sp) */
- pascal void ScrapCopy(Handle *h);
- pascal void ScrapEmpty(void);
- pascal void ScrapPaste(Boolean pasteAll, ResType typeToPaste, short resFile);
- pascal void WritePreferences (ResType prefType, short prefId, Str255 prefName, Handle prefHandle);
- pascal void GetErrorText (short error, StringPtr errorText);
- pascal Boolean PlaySyncSound(short which, Handle sndHandle);
-
-
-